package com.aierkeji.call.b2c.controller;

import java.util.Map;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.aierkeji.call.b2c.contants.Contants;
import com.aierkeji.call.b2c.service.AkjCallClueStatisticsService;
import com.aierkeji.call.b2c.util.ResultMapHelper;

@RestController
@RequestMapping("callClueStatistics")
public class AkjCallClueStatisticsController extends BaseController {

	private final Logger log = LogManager.getLogger(getClass());

	@Autowired
	AkjCallClueStatisticsService akjCallClueStatisticsService;

	@PostMapping("updateStatistics")
	@RequiresRoles(value = { Contants.ROLE_ID_MANAGER }, logical = Logical.OR)
	public Map<String, Object> updateStatistics(@RequestBody Map<String, Object> map) {
		
		 try {
			 	return akjCallClueStatisticsService.putStaticsQueue(map);
			} catch (Exception e) {
				log.error("AkjCallClueStatisticsController.updateStatistics errror --- map:{}", map, e);
				return ResultMapHelper.failure(e.getMessage());
				
			}
	}

	@PostMapping("getUserStatistics")
	public Map<String, Object> getUserStatistics(@RequestBody Map<String, Object> map) {

		return akjCallClueStatisticsService.getUserStatistics(map);
	}

	@PostMapping("getStatisticsByAssigneUser")
	public Map<String, Object> getStatisticsByAssigneUser(@RequestBody Map<String, Object> map) {

		return akjCallClueStatisticsService.getStatisticsByAssigneUser(map);
	}

}
